import Vue from 'vue'
import Vuex from 'vuex'

import {
  testSubjectsErrorQuery,
  testSubjectsErrorDelete,
  testSubjectsErrorAdd,
  testSubjectsErrorUpdate,
  testSubjectsErrorDeleteBatch,
  testSubjectsErrorCheckSubjects,
  testSubjectsErrorDeleteBySubjectsId,
} from '@/api/admin/exam/testSubjectsError'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  //试题增删改查
  async queryTestSubjectsError({ commit }, listQuery) {
    let res = await testSubjectsErrorQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async delTestSubjectsError({ commit }, row) {
    let res = await testSubjectsErrorDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async delTestSubjectsErrorBySubjectsId({ commit }, row) {
    let res = await testSubjectsErrorDeleteBySubjectsId(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addTestSubjectsError({ commit }, data) {
    let res = await testSubjectsErrorAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateTestSubjectsError({ commit }, data) {
    let res = await testSubjectsErrorUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async deleteBatchTestSubjectsError({ commit }, data) {
    let res = await testSubjectsErrorDeleteBatch(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async checkTestSubjectsError({ commit }, data) {
    let res = await testSubjectsErrorCheckSubjects(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
